﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PROAD
{
    public partial class Adm : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(Session["CO_PROFISSIONAL"] != null)
                {
                    if (Session["CO_PERFIL"].ToString() == "1")
                    {
                        lblInfoUsuario.Text = Session["NO_PROFISSIONAL"].ToString() + " - " + Session["DT_ULT_ACESSO"].ToString();
                        MarcarMenu();
                    }else
                    {
                        Session.RemoveAll();
                        Response.Redirect("/login.aspx");
                    }
                }else
                {
                    Session.RemoveAll();
                    Response.Redirect("/login.aspx");
                }
            }
        }

        protected void linkSair_Click(object sender, EventArgs e)
        {
            Session.RemoveAll();
            Response.Redirect("/login.aspx");
        }

        protected void MarcarMenu()
        {
            string path = HttpContext.Current.Request.Url.AbsolutePath;

            switch (path)
            {
                case "/admin/Consulta/consultaUnidadeCadastrada.aspx":
                    menuUS.Style.Add("background-color", "#5ca09f");
                    break;

                case "/admin/Forms/FormUsb.aspx":
                    menuUS.Style.Add("background-color", "#5ca09f");
                    break;

                case "/admin/Consulta/ConsultaListaEsf.aspx":
                    menuES.Style.Add("background-color", "#5ca09f");
                    break;

                case "/admin/Forms/FormEsf.aspx":
                    menuES.Style.Add("background-color", "#5ca09f");
                    break;

                case "/admin/Consulta/ConsultaProfissionais.aspx":
                    menuPS.Style.Add("background-color", "#5ca09f");
                    break;

                case "/admin/Forms/FormProfissionais.aspx":
                    menuPS.Style.Add("background-color", "#5ca09f");
                    break;
                case "/admin/Forms/formConfigAgenda.aspx":
                    menuConfig.Style.Add("background-color", "#5ca09f");
                    break;
                case "/admin/Relatorio/relAdmin.aspx":
                    menuRel.Style.Add("background-color", "#5ca09f");
                    break;
                    
            }

        }

    }
}